package com.info33.platform.business.app.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.info33.platform.business.app.dao.AppTenantApplyDao;
import com.info33.platform.business.app.dto.AppTenantApplyDTO;
import com.info33.platform.business.app.entity.AppTenantApply;
import com.info33.platform.business.app.service.AppTenantApplyService;
import com.info33.platform.common.mvc.vo.Result;
import com.info33.platform.system.dao.SysUserDao;
import com.info33.platform.system.service.SysTenantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author admin
 */
@Service
public class AppTenantApplyServiceImpl extends ServiceImpl<AppTenantApplyDao, AppTenantApply> implements AppTenantApplyService {

    @Autowired
    private SysUserDao sysUserDao;
    @Autowired
    private AppTenantApplyDao appTenantApplyDao;
    @Autowired
    private SysTenantService sysTenantService;

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public Result<Object> pcAgree(AppTenantApplyDTO dto) {
        AppTenantApply entity = new AppTenantApply();
        entity.setId(dto.getId());
        entity.setRemarks(dto.getRemarks());
        entity.setAudit(1);
        if (appTenantApplyDao.updateById(entity) != 1) {
            return Result.error(Result.RESULT_ERROR_PUBLIC_MSG);
        }
        return sysTenantService.pcAgree(dto, appTenantApplyDao.selectById(dto.getId()));
    }

}